package com.sskj.cndragon.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.cndragon.bean.AwardNoticeBean;
import com.sskj.cndragon.bean.TurntableBean;
import com.sskj.cndragon.http.HttpConfig;
import com.sskj.cndragon.ui.activity.TurntableActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;

public class TurntableActivityPresenter extends BasePresenter<TurntableActivity> {

    public void getTableDatas() {
        httpService.getTableDatas()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<TurntableBean>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<List<TurntableBean>>> response) {
                        HttpData<List<TurntableBean>> body = response.body();
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.updataTables(body.getData());
                        }
                    }
                });
    }

    public void getTicketsCount(String userID) {
        httpService.getTicketsCount(userID)
                .tag(this)
                .execute(new JsonCallBack<HttpData<String>>() {
                    @Override
                    public void onSuccess(Response<HttpData<String>> response) {
                        HttpData<String> body = response.body();
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.getTicketsOK(body.getData());
                        } else {
                            ToastUtil.showShort(body.getMsg());
                        }
                    }
                });
    }

    public void chouJiang(String userID) {
        httpService.chouJiang(userID)
                .tag(this)
                .execute(new JsonCallBack<HttpData<TurntableBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<TurntableBean>> response) {
                        HttpData<TurntableBean> body = response.body();
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.chouJiangOK(body.getData());
                        } else {
                            ToastUtil.showShort(body.getMsg());
                        }

                    }
                });
    }

    public void getAwardList() {
        httpService.getAwardList()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<AwardNoticeBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<AwardNoticeBean>>> response) {
                        HttpData<List<AwardNoticeBean>> body = response.body();
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.updataAwardList(body.getData());
                        }
                    }
                });
    }
}
